package mortal.game.manager
{
	import Framework.Util.*;
	import Message.Db.Tables.*;
	import Message.Public.*;
	import com.gengine.core.frame.*;
	import com.gengine.global.*;
	import com.mui.controls.*;
	import flash.display.*;
	import mortal.common.error.*;
	import mortal.game.events.*;
	import mortal.game.model.*;
	import mortal.game.mvc.*;
	import mortal.game.resource.*;
	//import mortal.game.scene.player.entity.*;
	//import mortal.game.view.chat.chatViewData.*;
	import mortal.mvc.core.*;
	
	public class MsgManager extends Object
	{
		private static var _msgBroadImpl:MsgBroadCastImpl = new MsgBroadCastImpl();
		//private static var _msgTipImpl:MsgTipTextImpl = new MsgTipTextImpl();
		//private static var _msgSpeakerImpl:MsgSpeakerImpl = new MsgSpeakerImpl();
		//private static var _msgFloatWordImpl:MsgFloatWordImpl = new MsgFloatWordImpl();
		//private static var _msgTaskShowImpl:MsgTaskShowImpl = new MsgTaskShowImpl();
		private static var _msgCopyTaskEndImpl:MsgCopyTaskEndImpl = new MsgCopyTaskEndImpl();
		public static var _msgIssmImpl:MsgIssmNoticeItemPanel = new MsgIssmNoticeItemPanel();
		
		public function MsgManager()
		{
			
		}
		
		public static function addIssmNoticeItemPanelStage(param1:DisplayObjectContainer) : void
		{
			param1.addChild(_msgIssmImpl);
			
		}
		
		public static function addBroadStage(param1:DisplayObjectContainer) : void
		{
			param1.addChild(_msgBroadImpl);
			
		}
		
		public static function addTipStage(param1:DisplayObjectContainer) : void
		{
			//param1.addChild(_msgTipImpl);
			
		}
		
		public static function addSpeakerStage(param1:DisplayObjectContainer) : void
		{
			//param1.addChild(_msgSpeakerImpl);
			
		}
		
		public static function systemError(param1:Object) : void
		{
			var _loc_2:int = 0;
			var _loc_6:Exception = null;
			var _loc_7:SErrorMsg = null;
			var _loc_3:String = "";
			var _loc_4:String = "";
			if (param1 is Exception)
			{
				_loc_6 = param1 as Exception;
				_loc_2 = _loc_6.code;
				_loc_3 = _loc_6.message;
				_loc_4 = "RMI系统错误:" + _loc_6.method + "，code：" + _loc_6.code;
				rmiCallback(_loc_6);
			}
			else if (param1 is SErrorMsg)
			{
				_loc_7 = param1 as SErrorMsg;
				_loc_2 = _loc_7.code;
				_loc_3 = _loc_7.message;
				_loc_4 = "cmd错误:,code：" + param1.code;
				errorCallback(_loc_7);
			}
			var _loc_5:* = ErrorCodeConfig.instance.getInfoByCode(_loc_2);
			if (ErrorCodeConfig.instance.getInfoByCode(_loc_2))
			{
				if (_loc_5.showServerMsg == 1)
				{
					addTips(_loc_4, _loc_3, _loc_5.display);
				}
				else
				{
					addTips(_loc_4, _loc_5.errorStr, _loc_5.display);
				}
				if (_loc_2 == ErrorCode.ErrorCell_EscortIsAttacked)
				{
					Dispatcher.dispatchEvent(new DataEvent(EventName.EscortIsAttacked));
					sendErrorMsgCount(_loc_5.errorStr, 20);
				}
			}
			else
			{
				addTips(_loc_4, ErrorCode.getErrorStringByCode(_loc_2), 0);
			}
			if (_loc_2 == ErrorCode.ErrorCell_ObstructNotFight)
			{
				//RolePlayer.instance.obstructNotFight();
			}
			else if (_loc_2 == ErrorCode.ErrorCell_CollectHasOwner)
			{
				Dispatcher.dispatchEvent(new DataEvent(EventName.CollectHasOwner));
			}
			else if (_loc_2 == ErrorCode.ErrorCell_FightToEntityNotOnline)
			{
				Dispatcher.dispatchEvent(new DataEvent(EventName.FightEntityNotOnLine));
			}
			else if (_loc_2 == ErrorCode.ErroeCell_CollectToEntityNotOnline)
			{
				Dispatcher.dispatchEvent(new DataEvent(EventName.ColloectTargetNotOnLine));
			}
			else if (_loc_2 == ErrorCode.ErrorCell_FightTooFar || _loc_2 == ErrorCode.ErrorCell_SkillTooFar)
			{
				Dispatcher.dispatchEvent(new DataEvent(EventName.FightTargetIsTooFar));
			}
			else if (_loc_2 == ErrorCode.ErrorCell_CollectDistanceTooFar)
			{
				Dispatcher.dispatchEvent(new DataEvent(EventName.CollectTargetIsTooFar));
			}
			else if (_loc_2 == ErrorCode.ErrorCell_InputPointError)
			{
				Dispatcher.dispatchEvent(new DataEvent(EventName.InputPointError));
			}
			
		}
		
		private static function addTips(param1:String, param2:String, param3:int) : void
		{
			if (Global.isDebugModle)
			{
				param1 = param1 + "，错误信息：" + param2;
			}
			else
			{
				if (param3 == 0)
				{
					
				}
				param1 = param2;
			}
			/*
			if (param3 & EShowArea._EShowAreaChat)
			{
				MsgManager.addChatMsg(param1, ChatType.Tips);
			}
			if (param3 & EShowArea._EShowAreaHistory)
			{
				MsgManager.addTipText(param1);
			}
			if (param3 & EShowArea._EShowAreaMiddle)
			{
				MsgManager.addBroadCast(param1);
			}
			*/
			
		}
		
		public static function resize() : void
		{
			/*
			_msgBroadImpl.stageResize();
			_msgTipImpl.stageResize();
			_msgSpeakerImpl.setPxy();
			_msgFloatWordImpl.stageResize();
			_msgTaskShowImpl.stageResize();
			_msgCopyTaskEndImpl.stageResize();
			*/
			
		}
		
		public static function addBroadCast(param1:Object, param2:MsgTypeImpl = null) : void
		{
			if (param1 == null)
			{
				
			}
			//param2 = param2 == null ? (MsgType.DefaultMsg) : (param2);
			//_msgBroadImpl.showNotice(param1.toString());
			
		}
		
		public static function addTipText(param1:Object, param2:MsgTypeImpl = null) : void
		{
			if (param1 == null)
			{
				
			}
			//param2 = param2 == null ? (MsgType.DefaultMsg) : (param2);
			//_msgTipImpl.showInfo(param1.toString(), param2.color, param2.delay);
			//GameController.sysHistory.addHistroy(param1, param2);
			
		}
		
		public static function addSpeakerText(param1:PlayerMiniInfo, param2:String, param3:MsgTypeImpl = null) : void
		{
			if (param1 == null)
			{
				
			}
			//param3 = param3 == null ? (MsgType.DefaultMsg) : (param3);
			//_msgSpeakerImpl.showSpeakerNotice(param1, param2, param3);
			
		}
		
		public static function addFloatWord(param1:Object, param2:MsgTypeImpl = null) : void
		{
			if (param1 == null)
			{
				
			}
			//param2 = param2 == null ? (MsgType.DefaultMsg) : (param2);
			//_msgFloatWordImpl.showWord(param1.toString());
			
		}
		
		public static function removeFloatWord() : void
		{
			//_msgFloatWordImpl.dispose();
			
		}
		
		public static function showTaskTarget(param1:TaskShowTargetInfo) : void
		{
			if (param1 == null)
			{
				
			}
			//_msgTaskShowImpl.showTarget(param1);
			
		}
		
		public static function removeTaskTarget() : void
		{
			//_msgTaskShowImpl.hide();
			
		}
		
		public static function showCopyEndStr(param1:String, param2:int, param3:int, param4:Function = null) : void
		{
			_msgCopyTaskEndImpl.show(param1, param2, param3, param4);
			
		}
		
		public static function hideCopyEndStr() : void
		{
			_msgCopyTaskEndImpl.hide();
			
		}
		
		public static function alertError(param1:int) : void
		{
			Alert.show("错误码：" + param1 + "  信息：" + ErrorCode.getErrorStringByCode(param1), "错误信息");
			
		}
		
		public static function alertIssm(param1:String) : void
		{
			
		}
		
		public static function addChatMsg(param1:Object, param2:String) : void
		{
			//GameController.chat.addTipMsg(param1, param2);
			
		}
		
		private static function sendErrorMsgCount(param1:String, param2:int) : void
		{
			var onEnterFrameHandler:Function;
			var value:* = param1;
			var num:* = param2;
			onEnterFrameHandler = function (param1:SecTimer) : void
			{
				MsgManager.addBroadCast(value);
				
			}
				;
			var timer:* = new SecTimer(1, num);
			timer.addListener(TimerType.ENTERFRAME, onEnterFrameHandler);
			timer.start();
			
		}
		
		private static function errorCallback(param1:SErrorMsg) : void
		{
			switch(param1.code)
			{
				case ErrorCode.ErrorPublic_CopyGroupNotExsit:
				{
					//NetDispatcher.dispatchCmd(ServerCommand.Copy_GroupNoExist, null);
					break;
				}
				default:
				{
					break;
				}
			}
			
		}
		
		private static function rmiCallback(param1:Exception) : void
		{
			switch(param1.code)
			{
				case ErrorCode.ErrorGate_TransportHadTask:
				{
					break;
				}
				default:
				{
					break;
				}
			}
			
		}
	}
}
